<template>
	<view>
		<uni-forms ref="form" :rules="{}">
			<uni-forms-item label="用户名" name="">
				<uni-easyinput  v-model="user.username"   placeholder="请输入用户名" />
			</uni-forms-item>
			<uni-forms-item label="密码" name="">
				<uni-easyinput type="password"   v-model="user.password" placeholder="请输入密码" />
			</uni-forms-item>
			<uni-forms-item label="学院" name="">
				<uni-combox  :candidates="user.cities" placeholder="请选择学院" v-model="user.city"></uni-combox>
			</uni-forms-item>
			</uni-forms-item>
			<uni-forms-item label="专业" name="">
				<uni-combox  :candidates="user.majors" placeholder="请选择专业" v-model="user.major"></uni-combox>
			</uni-forms-item>
			<uni-forms-item label="姓名" name="">
				<uni-easyinput type="name"   v-model="user.name" placeholder="请输入姓名" />
			</uni-forms-item>
			<uni-forms-item label="邮箱" name="">
				<uni-easyinput type="email"   v-model="user.email" placeholder="请输入邮箱" />
			</uni-forms-item>
			<uni-forms-item label="" name="">
				<button type="primary" @click="register">注册</button>
			</uni-forms-item>
		</uni-forms>
	</view>
</template>

<script>
	export default {
		data() {
					return {
						user:{
							username:'',
							password:'',
							city:'',
							cities:['信息工程学院','文学院','金融与贸易学院','音乐舞蹈学院','商学院'],
							major:'',
							majors:['移动应用开发专业','汉语言文学专业','金融学专业','音乐学专业','工商管理专业'],
							name:'',
							email:'',
							
							
						}
					}
				},

		methods: {
				register(e) {
					uni.request({
						url: 'http://localhost:8090/freshmenapp/user/register',
						method: 'POST',
						data: this.user,
						success: res => {
							if (res.data.success) {
								uni.showToast({
									title: '注册成功',
									duration:3000
								});
							} else {
								uni.showToast({
									title: '注册失败',
									icon: 'none'
								});
							}
						},
						fail: () => {},
						complete: () => {}
					});
				},
				onLoad: () => {
					uni.onTabBarMidButtonTap(function(e) {
						console.log(e);
					})
				}
			}
		}
</script>

<style>
view{
	margin: 10px 5px 0 5px ;
	
}
</style>
